package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import service.MessageService;
import service.impl.MessageServiceImpl;
import entity.Message;

public class MessageDetailServlet extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		Message messageDeatail = new Message(); 
		MessageService ms = new MessageServiceImpl();
		int mid = Integer.parseInt(request.getParameter("mid"));
		messageDeatail = ms.getMessageByMid(mid);
		ms.updateMessage(mid);
		getServletContext().setAttribute("message", messageDeatail);
		request.getRequestDispatcher("./messageDetail.jsp").forward(request, response); 
	}

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		this.doGet(request, response);
	}

}
